

package formServlets;
import java.io.IOException;
import java.io.PrintWriter;

import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.DatastoreAttributes;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.FetchOptions;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;

import javax.servlet.http.HttpServlet;

//import guestbook.PMF;

public class  AddPlaceInfoServlet  extends HttpServlet  {

	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		getServletContext().getRequestDispatcher("SNSP.html").forward(req, resp);
	}
 
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		System.out.println("In AddPlaceInfoServlet");
		PrintWriter pw = response.getWriter(); 
		
		DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
		String country= request.getParameter("country");
		System.out.println(country);
		String state= request.getParameter("state");
		String placeId=country+state;
		Entity user = new Entity("PlaceInfo",placeId);
		user.setProperty("placeId", placeId);
		user.setProperty("Country", country);
		user.setProperty("State", state);
		datastore.put(user);
		response.sendRedirect("addData/addCountryState.html");

	}
 
}
